
Ext.onReady(function(){ 

Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'under';

var record_start = 0; 

var sm = new Ext.grid.CheckboxSelectionModel();
var cm=new Ext.grid.ColumnModel([ 
sm,
new Ext.grid.RowNumberer({header: "编号",
width:40, 
renderer:function(value,metadata,record,rowIndex){ 
return record_start + 1 + rowIndex; 
} 
}),
{header:'信用评级',dataIndex:'secondPdlevel',width:100,sortable:true}, 
{header:'评级流水号',dataIndex:'serialNo',width:120, hidden:true},
{header:'信用评级生成日期',dataIndex:'secondDate',width:100,sortable:true},
{header:'PD值',dataIndex:'secondPdvalue',width:100,sortable:true, hidden:true},
{header:'评级到期日',dataIndex:'endDate',width:100,sortable:true, hidden:true},
{header:'财报会计月份',dataIndex:'reportDate',width:100,sortable:true, hidden:true},
{header:'打分卡模型',dataIndex:'modelId',width:220,sortable:true},
{header:'初评人',dataIndex:'firstUserId',width:100,sortable:true},
{header:'初评机构',dataIndex:'firstOrgId',width:100,sortable:true},
{header:'评级状态',dataIndex:'phaseStat',width:120,sortable:true},
]); 
var ds=new Ext.data.Store({ 
proxy:new Ext.data.HttpProxy({
url:'rating/listHistoryPD.do',
method:'POST'
}), 
reader:new Ext.data.JsonReader({ 
totalProperty:'total',  
root:'resultData'},[
{name:'serialNo'}, 
{name:'secondDate'}, 
{name:'secondPdlevel'}, 
{name:'endDate'}, 
{name:'modelId'},  
{name:'reportDate'},  
{name:'firstUserId'},  
{name:'firstOrgId'},  
{name:'secondPdvalue'},
{name:'phaseStat'}
]) 
}); 

 

var grid=new Ext.grid.GridPanel({ 
id:'myCustomers',
renderTo:"rating_list", 
stripeRows:true,//斑马线效果
title:"历史评级信息", 
height:500, 
cm:cm,
store: ds, 
loadMask: { msg: "加载中..." }, 
viewConfig: {   
                            forceFit:true   
            },   
            bbar: new Ext.PagingToolbar({   
                pageSize: 20,   
                store: ds,   
                displayInfo: true,   
                displayMsg: '第{0} 到 {1} 条数据 共{2}条',   
                emptyMsg: "没有数据" ,
                doLoad : function(start){ 
   record_start = start; 
var o = {}, pn = this.getParams(); 
          o[pn.start] = start; 
          o[pn.limit] = this.pageSize; 
this.store.load({params:o}); 
     }  
            }),
 tbar: [
        {text:'评级报告',handler: startPD}
 ]              
});
ds.load({params:{start:0,limit:20}}); 


function startPD(){
	if (grid.getSelectionModel().getSelections()[0] == undefined) { 
		Ext.Msg.alert("提示", "请选中要操作的项！"); 
	}
	else{
		var serialNo = grid.getSelectionModel().getSelections()[0].data.serialNo;
		window.location.href="rating/showRatingReport.do?serialNo="+serialNo;
	}
	//window.location.href="view/rating/CustomerRating_RatingProcess.jsp";
}

function rowdblclickFn(grid, rowIndex, e){//双击事件  
             var row = grid.getStore().getAt(rowIndex); 
             var selectedCustId = row.get("serialNo");
             Ext.Ajax.request({
  url:'checkRequest.do',
  method:'GET',
  success:function(){
  window.location.href="rating/showRatingReport.do?serialNo="+selectedCustId;
  },failure:function(){
    Ext.MessageBox.alert("请求异常！");
  }
});  
//  window.location.href="view/customer/CheckCustomer_General.jsp?custId="+selectedCustId;
}   
        grid.addListener('rowdblclick',rowdblclickFn);
/*grid.on('rowdblclick',function(){ window.location.href="view/customer/CheckCustomer_General.jsp" });*/
}); 